<?php
$sn = empty($_REQUEST['sn']) ? 0 : trim($_REQUEST['sn']);
$isdo = empty($_POST['isdo']) ? '' : trim($_POST['isdo']);

if(empty($isdo)){
	if(empty($sn)){
		sysinfo('订单信息丢失', $url = '', $ttl = 2000);
	}
	$oOrder = new Order();
	$orderinfo = $oOrder->get_order_by_sn($sn, '*');
	
	
	$orderlink = "./index.php?frm=user&mdl=order&do=view&sn={$sn}";
	$custom = array(
		'links'	=> array(
			'查看订单详细信息'	=> $orderlink,
		),
	);	
	if($orderinfo['state'] < 2){
		$custom['title'] = '当前订单还未完成，不能评价';
		sysinfo($custom, $url = $orderlink, $ttl = 5000);
	}elseif($orderinfo['state'] > 2){
		$custom['title'] = '您已经评价过本次交易了！';
		sysinfo($custom, $url = $orderlink, $ttl = 5000);
	}
	
	$orderinfo['addtime'] = ftime($orderinfo['addtime']);
	$vars['orderinfo'] = $orderinfo;
	// 配送方式
	$deliverys = cache_read('deliverys.php');
	$vars['deliveryinfo'] = $deliverys[$orderinfo['delivery']];
	
	// 支付方式
	$payments = cache_read('payments.php');
	$vars['paymentinfo'] = $payments[$orderinfo['payment']];
	
	// 订单商品
	$goodslist = $oOrder->get_order_goods_all($sn, $detail = true);
	if(!empty($goodslist)){
		$vars['goodslist'] = array();
		foreach($goodslist as $goods){
			if(!empty($goods['goodsinfo']['filename'])){
				$goods['url'] = PUB_DIR.'goods/'.$goods['goodsinfo']['filename'].'.html';
			}else{
				$goods['url'] = PUB_DIR.'goods/'.time_to_path($goods['goodsinfo']['addtime']).'/'.$goods['goodsinfo']['id'].'.html';
			}
			$vars['goodslist'][] = $goods;
		}
		//$vars['goods_cost'] = $orderinfo['cost'];
		//$vars['goods_weight'] = $orderinfo['weight'];
	}
	
}else{
	$oComment = new Comment();
	$r = $oComment->comment($sn, $_POST['score_desc'], $_POST['score_serv'], $_POST['score_speed'], $_POST['score_descs'], $_POST['contents']);
	ajax_msg($r['result'], $r['rmsg'], $callback = 'comment_callback', $synjs = '', $ttl = 2000);
}
?>